<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 *用户管理
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
if($_RQ['op']=='list'){
	$params=array();
	$params['uniacid']=$_SESSION['uniacid'];
	if(!empty($_RQ['name'])){
		$params['name like']='%'.trim($_RQ['name']).'%';
		$return['params']['name']=$_RQ['name'];
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$fields=array('id','uniacid','name','mobile','age','sex','coupon','address','createtime');
	$list=pdo_getslice('jy_yuyue_user',$params,array($pindex,$psize),$total,$fields,'','id desc');
	if($list){
		foreach($list as &$item){
			$item['nickname']=pdo_getcolumn('core_members',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['id']),'nickname');
			
		
		}
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>array(
			array('op'=>'list','title'=>'用户列表'),
		),
		'list'=>array('data'=>'list','edit'=>false,'list'=>array(
			array('name'=>'name','title'=>'姓名','type'=>'string'),
			array('name'=>'nickname','title'=>'昵称','type'=>'string'),
			array('name'=>'mobile','title'=>'电话','type'=>'string'),
			//array('name'=>'sex','title'=>'性别','type'=>'radio','options'=>'status'),
			array('name'=>'address','title'=>'地址','type'=>'string'),
			array('name'=>'coupon','title'=>'优惠券','type'=>'string'),
		)),
		'search'=>array(
			array('name'=>'title','title'=>'用户姓名','type'=>'string'),
		)
	);
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='del'){
	$del=trim($_RQ['del'],';');
	if($del){
		$del=explode(';',$del);
	}else{
		$del=array();
	}
	if($_RQ['id']){
		$del[]=$_RQ['id'];
	}
	foreach($del as $id){
		$id=intval($id);
		if($id){
			pdo_delete('jy_yuyue_user',array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
		}
	}
	exi('删除成功！');
}